(function (vc) {
    vc.extends({
        propTypes: {
            emitChooseBlacklist: vc.propTypes.string,
            emitLoadData: vc.propTypes.string
        },
        data: {
            chooseBlacklistInfo: {
                blacklists: [],
                _currentBlacklistName: '',
            }
        },
        _initMethod: function () {
        },
        _initEvent: function () {
            vc.on('chooseBlacklist', 'openChooseBlacklistModel', function (_param) {
                $('#chooseBlacklistModel').modal('show');
                vc.component._refreshChooseBlacklistInfo();
                vc.component._loadAllBlacklistInfo(1, 10, '');
            });
        },
        methods: {
            _loadAllBlacklistInfo: function (_page, _row, _name) {
                var param = {
                    params: {
                        page: _page,
                        row: _row,
                        communityId: vc.getCurrentCommunity().communityId,
                        name: _name
                    }
                };

                //发送get请求
                vc.http.apiGet('blacklist.listBlacklists',
                    param,
                    function (json) {
                        var _blacklistInfo = JSON.parse(json);
                        vc.component.chooseBlacklistInfo.blacklists = _blacklistInfo.blacklists;
                    }, function () {
                        console.log('请求失败处理');
                    }
                );
            },
            chooseBlacklist: function (_blacklist) {
                if (_blacklist.hasOwnProperty('name')) {
                    _blacklist.blacklistName = _blacklist.name;
                }
                vc.emit($props.emitChooseBlacklist, 'chooseBlacklist', _blacklist);
                vc.emit($props.emitLoadData, 'listBlacklistData', {
                    blacklistId: _blacklist.blacklistId
                });
                $('#chooseBlacklistModel').modal('hide');
            },
            queryBlacklists: function () {
                vc.component._loadAllBlacklistInfo(1, 10, vc.component.chooseBlacklistInfo._currentBlacklistName);
            },
            _refreshChooseBlacklistInfo: function () {
                vc.component.chooseBlacklistInfo._currentBlacklistName = "";
            }
        }

    });
})(window.vc);
